﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TianYuan.Core.Attributes
{
    /// <summary>
    /// 权限字符串
    /// </summary>
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true)]
    public class RequiresPermissionsAttribute : Attribute
    {
        /// <summary>
        /// 资源代码
        /// </summary>
        public string Code { set; get; }
        /// <summary>
        /// 名称（可选）
        /// </summary>
        public string Name { set; get; }
        /// <summary>
        /// 用code构造一个权限注解
        /// </summary>
        /// <param name="code">code</param>
        public RequiresPermissionsAttribute(string code):this(code,code)
        {

        }
        /// <summary>
        /// 用code/name构造一个权限注解
        /// </summary>
        /// <param name="code">code</param>
        /// <param name="name">名称</param>
        public RequiresPermissionsAttribute(string code, string name)
        {
            Code = code.ToLower();
            Name = name.ToLower();
        }
    }
}